//
//  JMTrashDetailController.m
//  PhotoLock
//
//  Created by 赵俊明 on 2017/7/15.
//  Copyright © 2017年 赵俊明. All rights reserved.
//

#import "JMTrashDetailController.h"
#import "JMDetailModel.h"
#import "JMBottomTabView.h"

@interface JMTrashDetailController ()<JMBottomTabViewDelegate>

@end

@implementation JMTrashDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"Trash";
    
    NSArray *imags = @[@"image", @"image", @"image",@"image", @"image", @"image", @"image"];
    
    for (int i = 0; i < imags.count; i ++) {
        
        JMDetailModel *model = [[JMDetailModel alloc] init];
        model.imageName = imags[i];
        [self.dataSource addObject:model];
    }
    
    self.collection.frame = CGRectMake(0, 0, kSCREEN_WIDTH, kSCREEN_HEIGHT-54);
    [self.collection reloadData];
    
    JMBottomTabView *bottom = [[JMBottomTabView alloc] initWithFrame:CGRectMake(0, kSCREEN_HEIGHT-54, kSCREEN_WIDTH, 54)];
    bottom.delegate = self;
    bottom.items = @[@"Remove All", @"Export"];
    [self.view addSubview:bottom];
}

- (void)buttomTabSelection:(NSInteger)index
{
    NSLog(@"导出／删除／添加");
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    JMDetailCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:collectionDetailID forIndexPath:indexPath];
    cell.model = self.dataSource[indexPath.row];
    return cell;
}

#pragma mark UICollectionViewDelegate
// 选中某item
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
}

// 动态设置每个分区的EdgeInsets
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(10, 10, 10, 10);
}

// 动态设置每行的间距大小
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 10;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake((kSCREEN_WIDTH-40)/3, (kSCREEN_WIDTH-40)/3);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
